﻿@model DSAAssignment.Models.ProductDetailModel

@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>@Html.DisplayFor(model => model.Name)</h2>
<script type="text/javascript">

    $(document).ready(function () {
        $('CommentF').hide();
    });

    function Add() {
        var id = '@Html.DisplayFor(model => model.ID)';
        /*$.ajax({
        //url: '/Product/AddToCart',
            
        type: "POST",
        url: "Product/AddToCart",
        data: "{productId:'" + id + "'}",
        contentType: "application/json; charset=utf-8",
        success: function (r) {
        alert("Done");
        },
        error: function (error) {
        debugger;
        alert("Error while adding to Cart!");
        }
        });*/

        $.post("/Product/AddToCart", { productId: id });

    }

    function show() {
        $('CommentF').Show();
    }
   
</script>
<fieldset>
    <legend>ProductDetailModel</legend>

    <div class="display-label">Name</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Name)
    </div>

    <div class="display-label">Price</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Price)
    </div>

    <div class="display-label">Features</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Features)
    </div>

    <div class="display-label">StockAvailable</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.StockAvailable)
    </div>

    <div class="display-label">Image</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Image)
    </div>

    <div class="display-label">NumberOfRatings</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.NumberOfRatings)
    </div>

    <div class="display-label">AverageRating</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.AverageRating)
    </div>

     <div class="display-label">Quantity</div>
    <div class="display-field">
        @Html.TextBox("Quantity")
    </div>

    @Html.ActionLink("Add To Cart", "AddProductsToCart",new{ quantity = "Quantity"})
    @Html.ActionLink("Back to List", "HomePage","Home")
</fieldset>

<legend>Comments</legend>

@Html.Action("Comments", "Website", new { ProductID = Model.ID})
